<template>
  <div id='echarsleft'>
    <slot>
    </slot>
    <div ref='main'
      class='main'></div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'echarsleft',
  data() {
    return {
      main: '',
      echart: '',
    }
  },
  mounted() {
    this.main = this.$refs.main
    this.echart = echarts.init(this.main)
    this.setOptions()
  },
  methods: {
    setOptions() {
      let option = {
        tooltip: {
          trigger: 'item',
        },
        series: [
          {
            name: '访问来源',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            labelLine: {
              show: true,
            },
            data: [
              { value: 1048, name: '完成成交' },
              { value: 735, name: '部分成交' },
              { value: 580, name: '撤单' },
              { value: 484, name: '待成交' },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 10,
                shadowColor: 'rgba(0, 0, 0, 0.5)',
              },
            },
          },
        ],
      }
      option && this.echart.setOption(option)
    },
  },
}
</script>

<style lang='less'>
#echarsleft {
  width: 100%;
  height: 100%;
  padding: 10px;
  padding-top: 20px;
  box-sizing: border-box;
  .main {
    height: 237px;
    width: 80%;
    margin-top: 40px;
    margin-left: 45px;
    &:div {
      width: 100% !important;
      height: 100% !important;
      canvas {
        width: 100% !important;
        height: 100% !important;
      }
    }
  }
  .el-icon-coin {
    color: rgb(103, 196, 250);
    font-size: 20px;
    margin-right: 8px;
    vertical-align: middle;
  }
  .list {
    margin-top: 10px;
    margin-left: 20px;
    li {
      color: rgb(77, 190, 255);
      margin-bottom: 12px;
      position: relative;
    }
    li:after {
      content: '';
      display: inline-block;
      position: absolute;
      left: -12px;
      top: 7px;
      width: 5px;
      height: 5px;
      background-color: rgb(77, 190, 255);
      border-radius: 50%;
    }
  }
  .infobox {
    display: flex;
    width: 100%;
    height: 82%;
    margin-top: 8px;
    .infobox-left,
    .infobox-right {
      flex: 1;
      border-radius: 8px;
      .infobox-left-title,
      .infobox-right-title {
        color: #fff;
        font-size: 14px;
        font-weight: 500;
        margin-left: 25px;
        margin-top: 10px;
      }
      .infobox-left-info,
      .infobox-right-info {
        width: 100%;
        height: 80%;
        padding: 10px;
        box-sizing: border-box;
        display: flex;
        flex-direction: row;
        .info-left,
        .info-right {
          flex: 1;
          text-align: center;
          align-self: center;
          color: #fff;
          position: relative;
          h3 {
            font-size: 36px;
          }
          h4 {
            font-weight: normal;
          }
        }
        .info-left:after {
          content: '';
          display: inline-block;
          position: absolute;
          width: 2px;
          height: 65px;
          background-color: rgba(255, 255, 255, 0.8);
          right: 0;
          top: -5px;
          border-radius: 50%;
        }
      }
    }
    .infobox-left {
      margin-right: 20px;
      background: url('/image/bg_0.f1493f69.png');
      background-size: cover;
      background-repeat: no-repeat;
    }
    .infobox-right {
      background: url('/image/bg_1.6cc399e5.png');
      background-size: cover;
      background-repeat: no-repeat;
      background-position: 50% 50%;
    }
  }
  .type-mid {
    margin-top: 10px;
    margin-left: 20px;
    h4 {
      display: inline-block;
      font-weight: 700;
    }
  }
  .block {
    margin-top: 10px;
    margin-left: 20px;
    width: 100%;
    .el-date-editor {
      width: 80%;
    }
  }
}
</style>